package com.pdd.service.Impl;

import com.pdd.beans.Order;
import com.pdd.dao.OrderMapper;
import com.pdd.service.OrderService;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @创建时间: 2018/8/15 - 14:44
 * @编写人员: 丷教皇
 * @文件描述:
 */
@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    @Setter
    private OrderMapper orderMapper;

    /**
     * 新增订单
     *
     * @param order 订单对象
     * @return 返回成功失败
     */
    public boolean addOrder(Order order) {
        return orderMapper.insertOrder(order) > 0;
    }

    /**
     * 按编号删除订单
     *
     * @param id 订单编号
     * @return 返回成功失败
     */
    public boolean delOrder(int id) {
        return orderMapper.deleteOrder(id) > 0;
    }

    /**
     * 更新订单
     *
     * @param order 订单对象
     * @return 返回成功失败
     */
    public boolean updOrder(Order order) {
        return orderMapper.updateOrder(order) > 0;
    }

    /**
     * 按编号查询订单
     *
     * @param id 订单编号
     * @return 返回结果
     */
    public Order getById(int id) {
        return orderMapper.selectById(id);
    }

    /**
     * 查询所有订单
     *
     * @return 返回结果
     */
    public List<Order> getAll() {
        return orderMapper.selectAll();
    }
}
